package br.com.iswe.acegi;

import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationException;
import org.springframework.security.AuthenticationManager;
import org.springframework.security.GrantedAuthority;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
import org.springframework.security.userdetails.UserDetails;

public class TesteAuthenticationManager implements AuthenticationManager {

	private String userName;
	
	@SuppressWarnings("serial")
	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        UserDetails userDetails = new  UserDetails(){
            public boolean isAccountNonExpired() {
                return false;
            }
            public boolean isAccountNonLocked() {
                return false;
            }

            public GrantedAuthority[] getAuthorities() {
                return null;
            }

            public boolean isCredentialsNonExpired() {
                return false;
            }

            public boolean isEnabled() {
                return false;
            }

            public String getPassword() {
                return null;
            }

            public String getUsername() {
                return userName;
            }
            
        };
        UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(userDetails,
                authentication.getCredentials(), userDetails.getAuthorities());
        return result;
    }

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}


}